﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Newtonsoft.Json;

namespace AUV5.DAL.Handler
{
    public class OrderInfoHandler
    {
        public IList<Model.OrderInfo> orderlist = new List<Model.OrderInfo>();
        public void GetFullList(object sender, object parameterObj, IList list)
        {
            Model.OrderInfo orderinfo = GetFullOrder(sender);
            if (orderinfo != null)
            {
                orderlist.Add(orderinfo);
            }
        }
        private Model.OrderInfo GetFullOrder(object sender)
        {
            try
            {
                if (sender != null)
                {
                    //获取用信息
                    Model.OrderInfo orderinfo = (Model.OrderInfo)sender;
                    Model.UserInfo user = new Model.UserInfo();
                    //BuyerName
                    user.UserID = orderinfo.Buyer;
                    Model.UserInfo buyer = new Model.UserInfo();
                    buyer = Dao.UserInfoSqlMapDao.Instance.GetDetail(user);
                    if (buyer != null)
                    {
                        orderinfo.BuyerName = buyer.UserName;
                    }
                    else
                    {
                        orderinfo.BuyerName = "找不到买家";
                    }
                    //SellerName
                    user.UserID = orderinfo.Seller;
                    Model.UserInfo seller = new Model.UserInfo();
                    seller = Dao.UserInfoSqlMapDao.Instance.GetDetail(user);
                    if (seller != null)
                    {
                        orderinfo.SellerName = seller.UserName;
                    }
                    else
                    {
                        orderinfo.Seller = "找不到卖家";
                    }

                    return orderinfo;
                }
                else
                {
                    return null;
                }
            }
            catch (Exception e)
            {
                throw new Exception("Error executing OrderInfoHandler,  Cause: " + e.Message, e);
            }

        }

    }
}
